Attribute VB_Name = "Module_OperateType"
Function SetTypeInsert(v As VisM, ByVal Code As String, ByVal Desc As String, _
                       ByVal stype As String) As String
    v.P1 = Code
    v.P2 = Desc
    v.P3 = stype
    v.Execute "$$Insert^DHCSTOPERATETYPE(P1,P2,P3)"
    If v.Error <> 0 Then
        MsgBox "error" + v.ErrorName
        SetTypeInsert = -1
        Exit Function
    End If
    
    If v.Value = "" Then
        SetTypeInsert = -2
        Exit Function
    End If
    
    SetTypeInsert = v.Value
End Function
Function SetTypeUpdate(v As VisM, ByVal Code As String, ByVal Desc As String, _
                       ByVal stype As String, ByVal typedr As String) As String
    v.P1 = typedr
    v.P2 = Code
    v.P3 = Desc
    v.P4 = stype
    v.Execute "$$Update^DHCSTOPERATETYPE(P1,P2,P3,P4)"
    If v.Error <> 0 Then
        MsgBox "error" + v.ErrorName
        SetTypeUpdate = -1
        Exit Function
    End If
    If v.Value <> "0" Then
        SetTypeUpdate = -2
        Exit Function
    End If
    SetTypeUpdate = v.Value
End Function
Function SetTypeDelete(v As VisM, ByVal typedr As String) As String
    v.P1 = typedr
    v.Execute "$$Delete^DHCSTOPERATETYPE(P1)"
    If v.Error <> 0 Then
        MsgBox "error" + v.ErrorName
        SetTypeDelete = -1
        Exit Function
    End If
    If v.Value <> 0 Then
        SetTypeDelete = -2
        Exit Function
    End If
    SetTypeDelete = v.Value
End Function
Sub SetRelativeTypeToDDLB(v As VisM, cb As ComboBox, ByVal inputtext As String)
    v.P0 = inputtext
    Call Restore_Connect(v)
    v.Execute "$$GetImpType^DHCSTOPERATETYPE(P0)"
    If v.Error <> 0 Then
        MsgBox "Error:" + v.ErrorName
        Exit Sub
    End If
    Dim cnt As Integer
    Dim i As Integer
    Dim typedr As Integer
    Dim typedesc As String
    
    cnt = Val(v.Value)
    If cnt > 0 Then
        cb.Clear
        Dim str_arr() As String
        Dim str_arr2() As String
        str_arr = Split(v.PLIST, v.PDELIM)
        For i = 0 To UBound(str_arr)
            str_arr2 = Split(str_arr(i), "&")
            typedr = Val(str_arr2(0))
            typedesc = str_arr2(1)
            cb.AddItem (typedesc)
            cb.ItemData(i) = typedr
        Next
    End If
End Sub

